﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GIMS.BLL;
using KPIS.GERP.GIMS.IBLL;
using KPIS.GERP.GIMS.MODEL;
using System.Data;

namespace KPIS.GERP.GIMS.APP.APP_UI.UserControl
{
    public partial class ICM_Pre_Purchase_Request : System.Web.UI.UserControl
    {
        IBLLResourceMasterItem bllItem = new ResourceMasterItemBLL();
        IList<PrePurchaseRequestItemInfo> infoListPprItem = new List<PrePurchaseRequestItemInfo>();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Resource_Item_Id"] == null)
            {
                panelExpense.Visible = true;
                panelItemDescr.Visible = false;
                panelPrice.Visible = true;
                panelItemWarehouse.Visible = false;
                lblExpense.Text = "รายจ่ายทดสอบ";
            }
            else
            {
                panelExpense.Visible = false;
                panelItemDescr.Visible = true;
                panelPrice.Visible = true;
                panelItemWarehouse.Visible = true;
                ResourceMasterItemInfo info = bllItem.GetResourceMasterItem(Convert.ToInt32(Session["Resource_Item_Id"]));
                if (info.Image_name.Length > 0)
                {
                    imgItem.ImageUrl = "../Image/ItemPicture/" + info.Image_name;
                }
                else
                {
                    imgItem.ImageUrl = "../Image/ItemPicture/Nopic.jpg";
                }
                lblDescr.Text = info.Descr;
            }
            LoadDataGrid();
        }

        private void LoadDataGrid()
        {
            Grid.DataSource = infoListPprItem;
            Grid.DataBind();
        }
    }
}